# -*- coding: utf-8 -*-
"""
-------------------------------------------------
# @Project  :pythonProject
# @File     :violator_counter
# @Date     :2021/8/26 17:42
# @Author   :zhumenglong
# @Software :PyCharm
-------------------------------------------------
"""

from wareHouse import *

class Counter:
    def __init__(self,file_path,Index_path,goal_path):
        self.file_path = file_path
        self.Index_path = Index_path
        self.goal_path = goal_path

    def get_keypoint(self):
        with open(self.Index_path, 'r', encoding='utf-8') as fp:
            while True:
                file_name = fp.readline()[:-1]
                json_name = ""
                pict_name = ""
                if len(file_name) > 0:
                    json_name = self.file_path + file_name + '_info.json'
                    pict_name = self.file_path + file_name + '.jpg'
                    Counter.draw_pic_jpg(self,file_name, json_name, pict_name)

                else:
                    break

    def draw_pic_jpg(self,file_name,json_name,pict_name):
        with open(json_name, 'r', encoding='utf-8') as f:
            # f.read()
            json_info = json.loads(f.read())
            img_info = method.cv2_imread(pict_name, -1)
            cv2.rectangle(img_info, (670, 110), (1100, 900), (0,255,255), 2)#最外
            cv2.rectangle(img_info, (710, 220), (1060, 430), (0, 250, 0), 2)
            cv2.rectangle(img_info, (880, 490), (970, 570), (0, 250, 0), 2)
            x1,y1,x2,y2 = 670,110,1100, 900
            kk1,kk2, salesman,wrist = 0, 0,0,0
            # print(json_info)
            print(pict_name)
            for i in json_info:
                # print(i)
                if i == "person":
                    for num in json_info[i]:
                        keypoint = []
                        person_feat = []
                        for j in num:
                            if j == "box":
                                cat_name = str(kk1)+"_person"
                                xmin = int(num[j]['x'])
                                ymin = int(num[j]['y'])
                                xmax = int(num[j]['x']) + int(num[j]['width'])
                                ymax = int(num[j]['y']) + int(num[j]['height'])
                                if (xmin > x1 and xmin < x2 and ymin > y1 and ymin < y2) or (xmax > x1 and xmax < x2 and ymin > y1 and ymin < y2):
                                    kk2+=1
                                color = (250, 0, 0)
                                cv2.rectangle(img_info, (int(xmin), int(ymin)), (int(xmax), int(ymax)), color,
                                              2)
                                font = cv2.FONT_HERSHEY_SIMPLEX
                                cv2.putText(img_info, cat_name, (int(xmin), int(ymin)), font, 1, color, 2)

                            elif j == "key_point":

                                keypoint_thresh_vis = 0.3

                                for ii in num[j]:
                                    keypoint.append(ii)
                                keypoint = np.array(keypoint)

                                keypoint = keypoint.reshape((1, -1, 3))
                                joint_visible = keypoint[:, :, 2] > keypoint_thresh_vis
                                kpts_num = keypoint.shape[1]
                                for i1 in range(keypoint.shape[0]):
                                    pts = keypoint[i1]
                                    for color_i, jp in zip(colors, main_joint_pairs):
                                        if jp[0] >= kpts_num or jp[1] >= kpts_num: continue
                                        if joint_visible[i1, jp[0]] and joint_visible[i1, jp[1]]:
                                            pt0 = pts[jp, 0]
                                            pt1 = pts[jp, 1]
                                            pt0_0, pt0_1, pt1_0, pt1_1 = int(pt0[0]), int(pt0[1]), int(
                                                pt1[0]), int(pt1[1])

                                            cv2.line(img_info, (pt0_0, pt1_0), (pt0_1, pt1_1), color_i, 3)

                            elif j == "feature":
                                for ii in num[j]:
                                    person_feat.append(ii)
                                person_feat = np.array(person_feat)
                                # print(person_feat)
                                score = Counter.is_sales(self,person_feat)
                                print(score)
                                if score > 0.75:
                                    salesman += 1
                                    pand = kk1
                                    left_pose, right_pose = Counter.bank_ssm(self,img_info, "", keypoint)

                                    print(left_pose)
                                    print(right_pose)
                                    if left_pose or right_pose:
                                        wrist += 1
                                    else:
                                        pass
                                else:
                                    pass

                                if kk1 > 0 and salesman > 0 and wrist > 0:
                                    cv2.putText(img_info, str(pand) + "_Ture" , (1200,200),
                                                        cv2.FONT_HERSHEY_SCRIPT_COMPLEX, 1,
                                                        (0, 0, 250), 2)
                                else:
                                    pass
                            elif j == "sale":
                                cv2.putText(img_info, str(kk1)+"_"+num[j], (num['box']['x'],num['box']['y']-20), cv2.FONT_HERSHEY_SCRIPT_COMPLEX, 1,
                                                (0, 0, 250), 2)
                        kk1+=1
                else:
                    cv2.putText(img_info, json_info[i], (1500,300),
                                cv2.FONT_HERSHEY_SCRIPT_COMPLEX, 1,
                                (0, 250, 250), 2)

            method.create_path(self.goal_path)

            path1 = './' + self.goal_path + '/' + file_name + '.jpg'

            method.cv2_imwrite_jpg(path1, img_info)

    def get_sim(self,f1,f2):
        return np.dot(np.array(f1),np.array(f2).T)

    def bank_ssm(self,cv_image, box, keypoint, keypoint_thresh_vis=0.3):
        def is_roi_left(pts, joint_pairs, joint_visible, attr):
            jp = joint_pairs[1]
            if joint_visible[jp[1]]:  # wrist point is visible
                # NOTE 判断手腕是否在ROI区域（超柜屏幕）是则返回True否则返回False
                arm_x1, arm_y1 = keypoint[0][9][0] - 20, keypoint[0][9][1] - 20
                arm_x2, arm_y2 = keypoint[0][9][0] - 20, keypoint[0][9][1] + 20
                arm_x3, arm_y3 = keypoint[0][9][0] + 20, keypoint[0][9][1] - 20
                arm_x4, arm_y4 = keypoint[0][9][0] + 20, keypoint[0][9][1] + 20
                numll = 0
                if ((arm_x1 > 880 and arm_x1 < 970) and (arm_y1 > 490 and arm_y1 < 570)) or (
                        (arm_x1 > 710 and arm_x1 < 1060) and (arm_y1 > 220 and arm_y1 < 430)):
                    numll += 1
                else:
                    pass
                if ((arm_x2 > 880 and arm_x2 < 970) and (arm_y2 > 490 and arm_y2 < 570)) or (
                        (arm_x2 > 710 and arm_x2 < 1060) and (arm_y2 > 220 and arm_y2 < 430)):
                    numll += 1
                else:
                    pass
                if ((arm_x3 > 880 and arm_x3 < 970) and (arm_y3 > 490 and arm_y3 < 570)) or (
                        (arm_x3 > 710 and arm_x3 < 1060) and (arm_y3 > 220 and arm_y3 < 430)):
                    numll += 1
                else:
                    pass
                if ((arm_x4 > 880 and arm_x4 < 970) and (arm_y4 > 490 and arm_y4 < 570)) or (
                        (arm_x4 > 710 and arm_x4 < 1060) and (arm_y4 > 220 and arm_y4 < 430)):
                    numll += 1
                else:
                    pass
                if numll > 0:
                    return True
                else:
                    return False
            else:
                return False

        def is_roi_right(pts, joint_pairs, joint_visible, attr):
            jp = joint_pairs[1]
            if joint_visible[jp[1]]:  # wrist point is visible
                # NOTE 判断手腕是否在ROI区域（超柜屏幕）是则返回True否则返回False
                arm_x1, arm_y1 = keypoint[0][10][0] - 20, keypoint[0][10][1] - 20
                arm_x2, arm_y2 = keypoint[0][10][0] - 20, keypoint[0][10][1] + 20
                arm_x3, arm_y3 = keypoint[0][10][0] + 20, keypoint[0][10][1] - 20
                arm_x4, arm_y4 = keypoint[0][10][0] + 20, keypoint[0][10][1] + 20
                numll = 0
                if ((arm_x1 > 880 and arm_x1 < 970) and (arm_y1 > 490 and arm_y1 < 570)) or (
                        (arm_x1 > 710 and arm_x1 < 1060) and (arm_y1 > 220 and arm_y1 < 430)):
                    numll += 1
                else:
                    pass
                if ((arm_x2 > 880 and arm_x2 < 970) and (arm_y2 > 490 and arm_y2 < 570)) or (
                        (arm_x2 > 710 and arm_x2 < 1060) and (arm_y2 > 220 and arm_y2 < 430)):
                    numll += 1
                else:
                    pass
                if ((arm_x3 > 880 and arm_x3 < 970) and (arm_y3 > 490 and arm_y3 < 570)) or (
                        (arm_x3 > 710 and arm_x3 < 1060) and (arm_y3 > 220 and arm_y3 < 430)):
                    numll += 1
                else:
                    pass
                if ((arm_x4 > 880 and arm_x4 < 970) and (arm_y4 > 490 and arm_y4 < 570)) or (
                        (arm_x4 > 710 and arm_x4 < 1060) and (arm_y4 > 220 and arm_y4 < 430)):
                    numll += 1
                else:
                    pass
                if numll > 0:
                    return True
                else:
                    return False
            else:
                return False

        left_arm = [[5, 7], [7, 9]]  # 9: "left_wrist"
        right_arm = [[6, 8], [8, 10]]  # 11: "right_wrist"

        # kpts_atrr = keypoint_attr.reshape((1,-1,2))
        keypoint = keypoint.reshape((1, -1, 3))
        joint_visible = keypoint[:, :, 2] > keypoint_thresh_vis
        kpts_num = keypoint.shape[1]
        for i in range(keypoint.shape[0]):  # for each person
            pts = keypoint[i]
            attr = None  # kpts_atrr[i]

            left_pose = is_roi_left(pts, left_arm, joint_visible[i], attr)
            right_pose = is_roi_right(pts, right_arm, joint_visible[i], attr)

        return (left_pose, right_pose)

    def is_sales(self,person_feat):
        template_feat = [  # 具体看json
            [-0.02566535584628582, 0.02786463499069214, 0.08234929293394089, -0.08903306722640991, -0.030921129509806633,
             0.062257956713438034, 0.049026504158973694, 0.10480169951915741, 0.09286357462406158, 8.170672663254663e-05,
             0.12380872666835785, 0.030929716303944588, 0.09031882137060165, 0.08163132518529892, 0.15030382573604584,
             0.034968674182891846, 0.09553197771310806, -0.015225156210362911, 0.11204708367586136, 0.03492219001054764,
             0.016583338379859924, -0.11860385537147522, 0.05264243111014366, 0.1095602959394455, -0.23152707517147064,
             0.03445979580283165, -0.062114227563142776, 0.10681518912315369, -0.07424142211675644, 0.06406882405281067,
             0.06262580305337906, 0.09431976079940796, -0.0426398329436779, 0.09106139093637466, 0.003878009505569935,
             -0.054598044604063034, -0.024454638361930847, -0.10279909521341324, -0.13970841467380524, 0.03954979404807091,
             -0.1301184743642807, 0.02079804800450802, 0.029394546523690224, -0.043288931250572205, -0.10486561059951782,
             0.029288943856954575, -0.08364999294281006, 0.0803627222776413, -0.0359063595533371, -0.21671849489212036,
             -0.042850561439991, -0.07413314282894135, 0.004719425458461046, 0.13571451604366302, 0.07380550354719162,
             0.10019358992576599, 0.0071050128899514675, -0.0043070209212601185, -0.07044664770364761, 0.159620463848114,
             0.08157496154308319, -0.019686970859766006, 0.14018100500106812, 0.12952089309692383, 0.02261010929942131,
             0.02450767531991005, 0.035898610949516296, 0.061171889305114746, -0.0720585510134697, -0.0708898976445198,
             0.07402537763118744, -0.025952309370040894, 0.05077150836586952, -0.12133137136697769, 0.04432295635342598,
             -0.08565499633550644, 0.042414385825395584, -0.16190961003303528, -0.12642647325992584, -0.05737415328621864,
             0.014968355186283588, 0.012184816412627697, 0.03110678866505623, -0.0024820691905915737, 0.17092224955558777,
             0.050664447247982025, 0.016474958509206772, -0.13800473511219025, -0.09501963108778, -0.09872179478406906,
             0.06677325814962387, 0.14682163298130035, 0.19487270712852478, -0.020082082599401474, -0.10694386065006256,
             0.006473821587860584, -0.18520474433898926, -0.0073096309788525105, -0.09814242273569107, 0.037780843675136566,
             -0.0128383319824934, 0.012772941030561924, -0.08573366701602936, -0.07085100561380386, 0.02123175375163555,
             -0.08019611984491348, 0.14586341381072998, -0.16783888638019562, -0.01394075620919466, 0.09847339987754822,
             -0.1555766612291336, -0.006537649314850569, 0.06495694816112518, -0.1664147526025772, 0.023880373686552048,
             0.0661102756857872, -0.03250482678413391, -0.09773445129394531, 0.028585616499185562, 0.054136209189891815,
             0.14191940426826477, -0.07925644516944885, 0.005463280715048313, -0.08985628187656403, -0.120846688747406,
             0.07929938286542892, -0.04189791530370712, -0.05130105838179588],
            [-0.14687411487102509, -0.020917605608701706, 0.08526774495840073, 0.029674822464585304, -0.042219288647174835,
             -0.015896862372756004, -0.02563411183655262, 0.06356223672628403, 0.08645734190940857, -0.006044952664524317,
             0.07405465841293335, 0.09808990359306335, 0.06424182653427124, 0.04962995648384094, 0.0458189994096756,
             0.0475311242043972, 0.16849461197853088, 0.006457085721194744, 0.12960019707679749, -0.09133375436067581,
             0.09246181696653366, -0.05999782681465149, -0.08779611438512802, 0.08254019916057587, -0.14979322254657745,
             0.01668260246515274, -0.043023206293582916, 0.1374955028295517, -0.04783453419804573, 0.11140283197164536,
             0.0759081169962883, 0.13887432217597961, -0.028537089005112648, 0.1442170888185501, 0.08227322995662689,
             -0.04879765957593918, -0.005991140380501747, 0.05913694202899933, -0.1210029274225235, -0.06190589815378189,
             -0.09284158051013947, -0.008349615149199963, -0.017183817923069, -0.050196755677461624, -0.10244475305080414,
             0.014841921627521515, -0.004688397515565157, 0.03816955164074898, -0.04167087376117706, -0.21342088282108307,
             0.04074329510331154, -0.08155330270528793, -0.03271222114562988, 0.22467386722564697, -0.04430855065584183,
             0.018382059410214424, -0.12826547026634216, -0.04293331131339073, -0.05276946350932121, 0.08774402737617493,
             0.10919011384248734, -0.0006965759675949812, 0.0447179451584816, 0.0935458391904831, -0.01967920921742916,
             -0.054605256766080856, 0.08494091778993607, -0.03190560266375542, 0.11124861240386963, 0.04465314373373985,
             -0.03628503903746605, -0.0612356923520565, 0.09180787950754166, -0.10710740834474564, 0.0626804456114769,
             -0.1028946116566658, 0.019534938037395477, -0.190113827586174, -0.007486394606530666, -0.03975233808159828,
             -0.004752053413540125, 0.044191110879182816, -0.027998298406600952, 0.0278086606413126, 0.0499318428337574,
             0.12261034548282623, 0.08135861903429031, 0.019088460132479668, -0.06091834977269173, 0.051823150366544724,
             0.14142002165317535, 0.004356530494987965, 0.1689937710762024, -0.038309235125780106, -0.12600919604301453,
             -0.05964028462767601, -0.08207065612077713, -0.037834733724594116, -0.17850004136562347, 0.038685012608766556,
             0.017527420073747635, -0.08501105010509491, -0.03881586343050003, 0.028839416801929474, -0.06196559593081474,
             -0.00545801967382431, 0.1943739652633667, -0.14059913158416748, 0.01592973805963993, 0.14285658299922943,
             -0.06480778008699417, -0.19848395884037018, 0.0014380692737177014, -0.04376854747533798, 0.05957718566060066,
             0.07613471895456314, 0.07786821573972702, -0.05981079116463661, -0.15106841921806335, 0.02500385232269764,
             0.09955337643623352, 0.08934919536113739, -0.0465664379298687, -0.2212347388267517, -0.12215053290128708,
             0.1195417046546936, 0.027214592322707176, -0.028171544894576073],
            [-0.015699928626418114, -0.008868466131389141, 0.13662119209766388, -0.041893813759088516,
             -0.029014788568019867, 0.05663996934890747, -0.10436685383319855, 0.055762335658073425, 0.07167894393205643,
             0.040738794952631, 0.0754101425409317, -0.009158660657703876, 0.18717433512210846, 0.18843451142311096,
             -0.059840038418769836, 0.07542455196380615, 0.05557167902588844, 0.07708710432052612, 0.08281594514846802,
             -0.01402804534882307, 0.03454800322651863, -0.07926707714796066, -0.007707484997808933, 0.14777788519859314,
             -0.009839597158133984, 0.0319417305290699, -0.062383074313402176, 0.005017295479774475, 0.004176296293735504,
             0.04759892448782921, 0.13697169721126556, 0.10062746703624725, 0.01559939794242382, 0.06942880898714066,
             0.03433338180184364, 0.10656958818435669, 0.031202325597405434, 0.026014599949121475, 0.027365313842892647,
             0.0420239232480526, -0.10482127964496613, -0.002113336930051446, 0.01315394788980484, -0.1471806913614273,
             -0.14226661622524261, -0.029624270275235176, 0.0007024607621133327, 0.011553077958524227, 0.008004864677786827,
             -0.07712709158658981, 0.07838394492864609, 0.01840684935450554, -0.021786142140626907, 0.17733129858970642,
             0.08265373110771179, 0.06679873168468475, -0.131690114736557, -0.029838338494300842, 0.10408037900924683,
             0.06982371211051941, -0.03916960209608078, 0.02400253526866436, 0.20804116129875183, 0.0860145315527916,
             0.14523272216320038, -0.06761207431554794, -0.06977096945047379, -0.030033113434910774, -0.06709788739681244,
             -0.026418600231409073, 0.04620550945401192, -0.07428006082773209, -0.10011180490255356, -0.1664959043264389,
             0.11681412905454636, -0.12302760034799576, 0.008854485116899014, -0.1364094614982605, -0.1812945157289505,
             -0.07558909803628922, -0.005135582759976387, -0.04336869344115257, 0.047817304730415344, -0.10734546929597855,
             0.07624650746583939, 0.03633522614836693, -0.08444307744503021, 0.012115388177335262, -0.03336870297789574,
             -0.02003362961113453, 0.15726791322231293, 0.05451960861682892, 0.25085142254829407, -0.021520841866731644,
             -0.08547036349773407, -0.05546732246875763, -0.13430920243263245, -0.009886565618216991, -0.06359176337718964,
             0.0054202452301979065, 0.044713132083415985, -0.0009182824869640172, -0.09052903950214386,
             0.019356481730937958, 0.023782383650541306, 0.0915011540055275, 0.19139695167541504, -0.15498048067092896,
             0.05489114299416542, 0.1174604594707489, -0.04389693960547447, -0.015305685810744762, -0.05184271186590195,
             -0.05789891257882118, 0.005584861151874065, 0.1991971731185913, -0.025927692651748657, -0.11410784721374512,
             -0.06550853699445724, -0.03511660546064377, 0.034720227122306824, 0.10036051273345947, 0.05520151928067207,
             -0.17746514081954956, -0.1483919322490692, 0.04912092536687851, -0.011883456259965897, -0.10475507378578186],
            [0.019437942653894424, 0.018584471195936203, 0.07008572667837143, -0.08078506588935852, 0.01703454554080963,
             0.08653493225574493, -0.0583093985915184, -0.059162501245737076, 0.006301660090684891, 0.10669977962970734,
             0.06803029775619507, 0.01900559663772583, 0.11126234382390976, 0.15698371827602386, -0.03445260599255562,
             0.0532539077103138, 0.044542405754327774, 0.07014061510562897, 0.07524054497480392, -0.023092789575457573,
             0.0011771389981731772, -0.023513872176408768, -0.011549804359674454, 0.05621716007590294, -0.13434095680713654,
             0.017050830647349358, -0.11793185025453568, 0.09590115398168564, -0.011709213256835938, 0.05136597529053688,
             0.12045764923095703, 0.07046426832675934, 0.0033316947519779205, 0.07241525501012802, 0.009583781473338604,
             0.033930424600839615, 0.0165608748793602, 0.07699072360992432, -0.11527035385370255, -0.006483897101134062,
             -0.08781713992357254, 0.02338012121617794, 0.002304510911926627, -0.08953309804201126, -0.11119522899389267,
             0.05263539031147957, -0.026534428820014, 0.08560805767774582, -0.08062737435102463, -0.13518381118774414,
             0.004535788670182228, -0.07437027990818024, -0.044115837663412094, 0.21325059235095978, 0.06657733023166656,
             0.061570342630147934, -0.10850082337856293, -0.012267855927348137, 0.07615052163600922, 0.010016840882599354,
             0.07147965580224991, 0.04913467913866043, 0.15909229218959808, 0.08569170534610748, 0.17704549431800842,
             0.0012025110190734267, -0.004579019267112017, -0.015822328627109528, -0.06534255295991898,
             -0.023688066750764847, 0.07084676623344421, -0.10018693655729294, -0.039157137274742126, -0.1843327283859253,
             0.11655641347169876, -0.06122457608580589, 0.07194862514734268, -0.15440401434898376, -0.2228832095861435,
             -0.05659656971693039, 0.004892299883067608, -0.09430775046348572, -0.02162942662835121, -0.06757201999425888,
             0.11371005326509476, 0.060881953686475754, -0.09468559920787811, -0.023148519918322563, -0.07694432139396667,
             0.010456634685397148, 0.19477838277816772, 0.11989796906709671, 0.1553666740655899, -0.1375296413898468,
             -0.07147485762834549, -0.039578355848789215, -0.16048651933670044, -0.04353492334485054, -0.10350056737661362,
             0.0727991908788681, -0.025309203192591667, 0.040298495441675186, -0.05045919865369797, 0.009989729151129723,
             -0.009548412635922432, 0.12016802281141281, 0.26520591974258423, -0.0838378369808197, 0.020245404914021492,
             0.15028461813926697, -0.046671319752931595, -0.014509627595543861, 0.03874483332037926, -0.06220312789082527,
             -0.0020503492560237646, 0.1269393116235733, 0.03525279462337494, -0.10999374091625214, -0.03526070713996887,
             -0.08713707327842712, 0.07444880157709122, 0.05308138206601143, 0.037375375628471375, -0.22751744091510773,
             -0.08079643547534943, 0.06214927136898041, 0.041769951581954956, -0.08959007263183594],
            [-0.041716452687978745, 0.038726676255464554, 0.18244920670986176, -0.08036372810602188, -0.05352332442998886,
             -0.05281585827469826, 0.07450491935014725, 0.0743807703256607, 0.016890419647097588, 0.09861347079277039,
             0.08083611726760864, 0.023613151162862778, 0.01971590518951416, 0.019280409440398216, 0.08382727950811386,
             0.006699416786432266, 0.12007301300764084, 0.035874709486961365, 0.13654664158821106, -0.10819528996944427,
             0.08338890969753265, -0.10043960809707642, -0.0625041276216507, 0.04858210310339928, -0.1460513472557068,
             -0.14815959334373474, -0.073613241314888, 0.12955063581466675, 0.04992390424013138, 0.14689812064170837,
             0.09949849545955658, 0.0593595877289772, -0.045077092945575714, 0.07393293082714081, -0.027784891426563263,
             -0.0126562574878335, -0.0872667133808136, -0.036608923226594925, -0.16233699023723602, 0.04557805508375168,
             -0.10743215680122375, 0.014884723350405693, 0.020455317571759224, -0.05035277083516121, -0.07319635152816772,
             -0.006143929436802864, -0.02624441497027874, 0.10519127547740936, -0.07244879752397537, -0.20715589821338654,
             0.018910348415374756, -0.14101620018482208, -0.007226032204926014, 0.21385428309440613, 0.021246349439024925,
             0.07704373449087143, -0.21844235062599182, -0.03267928212881088, -0.01725991629064083, 0.14711378514766693,
             0.0401219017803669, -0.04056914150714874, 0.007751242257654667, 0.1201791763305664, -0.040028758347034454,
             -0.03113682009279728, 0.04821763187646866, -0.008051479235291481, 0.12182275205850601, -0.03327593207359314,
             0.014680339954793453, -0.05480637773871422, 0.017739450559020042, -0.16268186271190643, 0.05802200734615326,
             0.03829232603311539, 0.02151835896074772, -0.15011553466320038, -0.10811300575733185, -0.06568862497806549,
             0.001685658935457468, 0.11172875761985779, -0.017358193174004555, 0.019581736996769905, -0.02837483584880829,
             0.024833140894770622, -0.04340386390686035, -0.038613736629486084, -0.04412390664219856, -0.08962778002023697,
             0.04417238011956215, -0.002292003482580185, 0.13304173946380615, -0.03822050988674164, -0.05825633555650711,
             -0.04499680921435356, 0.018740670755505562, -0.008311108686029911, -0.18905630707740784, -0.028586605563759804,
             -0.05418115481734276, -0.03300674632191658, -0.11844803392887115, 0.027981407940387726, -0.03552820160984993,
             0.003552511101588607, 0.25729742646217346, -0.05186785012483597, 0.00042421254329383373, 0.12980760633945465,
             -0.13966718316078186, -0.11313816159963608, -0.014808240346610546, -0.11789139360189438, 0.014057287946343422,
             0.04014444723725319, 0.07597954571247101, -0.09435766190290451, -0.07830841094255447, 0.0015420151175931096,
             0.10066477209329605, 0.057497330009937286, -0.057329289615154266, -0.1791101098060608, -0.18810254335403442,
             0.05118615925312042, -0.030918730422854424, -0.08591175079345703],
            [-0.013217361643910408, -0.08166968077421188, 0.06909047067165375, -0.10517716407775879, -0.01783183217048645,
             0.024781491607427597, -0.02839556150138378, 0.05351391062140465, -0.027829894796013832, 0.04504857212305069,
             0.10504277795553207, -0.017264697700738907, 0.09579034894704819, 0.046273279935121536, 0.06708793342113495,
             0.012070433236658573, 0.1055099293589592, -0.04551662877202034, 0.24802467226982117, 0.07252917438745499,
             0.05078556761145592, -0.10762349516153336, -0.10487034916877747, 0.07685242593288422, -0.15987934172153473,
             -0.07745037227869034, -0.007515162229537964, 0.14919762313365936, -0.002529838588088751, 0.03181745484471321,
             0.12268970906734467, 0.09819414466619492, -0.07932216674089432, 0.1184040829539299, 0.07308565825223923,
             -0.012950588017702103, -0.037940241396427155, -0.06968651711940765, -0.11134039610624313, -0.10852276533842087,
             -0.19859331846237183, -0.03469580411911011, -0.01648673787713051, -0.04321015998721123, -0.10197680443525314,
             -0.09723915159702301, 0.011060422286391258, 0.07946576178073883, -0.04294269531965256, -0.23271247744560242,
             -0.03230849280953407, -0.0728033259510994, -0.05948192998766899, 0.14618146419525146, -0.03395841643214226,
             0.06430291384458542, -0.16492488980293274, -0.03318058326840401, -0.061198268085718155, 0.09230269491672516,
             0.07104817777872086, -0.03994855284690857, 0.07422440499067307, 0.13671930134296417, 0.08143988251686096,
             -0.02252579666674137, 0.01599164865911007, -0.018358197063207626, 0.10162464529275894, 0.027078572660684586,
             -0.013016317039728165, -0.10713263601064682, 0.14124749600887299, -0.18118520081043243, 0.012979620136320591,
             -0.06370033323764801, -0.007631669752299786, -0.14052946865558624, -0.17663709819316864,
             -0.0003157803730573505, 0.13433688879013062, 0.03834670037031174, -0.02197159454226494, -0.008786466903984547,
             0.0322796106338501, -0.001902798074297607, -0.023671340197324753, -0.014136754907667637, -0.04448585584759712,
             -0.057899195700883865, 0.02834785170853138, 0.013172744773328304, 0.19457468390464783, -0.04512389004230499,
             -0.12395570427179337, 0.030934667214751244, -0.12347384542226791, 0.07271690666675568, -0.11643236130475998,
             0.015573250129818916, 0.007284577004611492, -0.020135510712862015, -0.07299413532018661, -0.06524816900491714,
             0.0024560277815908194, -0.0007917732000350952, 0.183740496635437, -0.21058934926986694, 0.015442371368408203,
             0.11810827255249023, -0.11068618297576904, -0.05365774780511856, -0.004141363315284252, -0.14468926191329956,
             0.028907006606459618, 0.0738234594464302, -0.013193173334002495, -0.0440242737531662, -0.04841669648885727,
             0.07824895530939102, 0.10104534029960632, 0.07787482440471649, -0.028996437788009644, -0.11848072707653046,
             -0.11129961162805557, 0.07744042575359344, -0.0007631060434505343, 0.025303710252046585],
            [-0.10604537278413773, -0.010226485319435596, -0.008219761773943901, -0.08575452119112015, -0.08034750074148178,
             -0.005652374587953091, -0.06570365279912949, -0.009026477113366127, 0.1264915019273758, 0.006046437192708254,
             0.03345649689435959, 0.034741614013910294, 0.061730820685625076, 0.053677983582019806, -0.07507981359958649,
             0.03696382790803909, 0.09693542122840881, -0.0852973535656929, 0.2551116645336151, 0.0502907931804657,
             0.00848205853253603, -0.11166846007108688, -0.04933493956923485, 0.19103118777275085, -0.12933744490146637,
             0.08616234362125397, 0.029049711301922798, -2.9677343263756484e-05, -0.14024268090724945, 0.06227191537618637,
             0.003312397049739957, 0.045397866517305374, -0.004657305311411619, 0.07898067682981491, 0.004241317510604858,
             -0.03733748942613602, 0.08934814482927322, -0.020006831735372543, -0.09516661614179611, -0.08177250623703003,
             -0.04093131422996521, -0.05340565741062164, -0.08353499323129654, -0.14435741305351257, -0.14146171510219574,
             -0.09014216810464859, -0.05412096157670021, 0.02255873754620552, 0.04360588639974594, -0.09452996402978897,
             -0.0031832121312618256, -0.0185032207518816, -0.0013404260389506817, 0.08832454681396484, 0.02198750339448452,
             0.08545047789812088, -0.08193254470825195, -0.0367768295109272, 0.024323780089616776, 0.19371218979358673,
             0.06492092460393906, 0.011223899200558662, 0.021895840764045715, 0.22580073773860931, 0.06817707419395447,
             -0.04238053411245346, 0.029312387108802795, 0.032346054911613464, -0.08828148990869522, 0.05774360150098801,
             0.08858975023031235, -0.05119163915514946, 0.08373411744832993, -0.1205119788646698, 0.11972061544656754,
             -0.11662616580724716, -0.05632410943508148, -0.05029713362455368, -0.15682558715343475, -0.08167733997106552,
             0.06213753670454025, 0.01813468150794506, 0.056432176381349564, -0.030177945271134377, 0.10815221816301346,
             -0.048819221556186676, 0.11155454069375992, -0.08593422174453735, -0.07555563747882843, -0.008383424021303654,
             0.03690250590443611, 0.017886614426970482, 0.2657910883426666, -0.0723615437746048, -0.04602250084280968,
             0.06445497274398804, -0.2646753489971161, 0.017181625589728355, -0.05265695974230766, 0.06114325299859047,
             -0.05128442868590355, -0.04605986922979355, -0.037980951368808746, 0.0849035233259201, 0.06347868591547012,
             -0.026836050674319267, 0.16396932303905487, -0.09769930690526962, 0.039010047912597656, 0.11448979377746582,
             -0.08192787319421768, -0.023006703704595566, 0.018213683739304543, -0.09735001623630524, -0.025305893272161484,
             0.08789385110139847, 0.005425211042165756, -0.05422242358326912, -0.15557315945625305, 0.019473467022180557,
             0.13623906672000885, -0.04377516731619835, 0.02978723868727684, -0.17624016106128693, -0.10641461610794067,
             0.07559528201818466, 0.04180581495165825, -0.09481624513864517],
            [-0.04486190900206566, 0.02507677488029003, -0.029629558324813843, -0.03381512686610222, -0.04978898912668228,
             0.004284535069018602, -0.02273600362241268, 0.07113350182771683, 0.07884561270475388, 0.024883929640054703,
             0.025852516293525696, -0.0013131139567121863, 0.013468480668962002, 0.026855075731873512, -0.05922951176762581,
             -0.0019505082163959742, 0.031267181038856506, -0.07656436413526535, 0.29486730694770813, 0.024347661063075066,
             0.060716766864061356, -0.07699163258075714, -0.03209976106882095, 0.20624233782291412, -0.15257708728313446,
             0.01911108009517193, -0.02620694972574711, 0.01710318773984909, -0.07739973813295364, 0.11476574093103409,
             0.052272360771894455, 0.1620054841041565, -0.058919984847307205, 0.10334008187055588, 0.10887797176837921,
             -0.037793442606925964, -0.07169914245605469, -0.07966607064008713, -0.05603256821632385, -0.00808404665440321,
             -0.11956708878278732, -0.0991891548037529, -0.0881110206246376, -0.059084177017211914, -0.16322176158428192,
             -0.07780569046735764, -0.059782907366752625, 0.018225135281682014, 0.006043568253517151, 0.049599241465330124,
             -0.015193014405667782, 0.02234482578933239, 0.032098833471536636, 0.06934364140033722, 0.033411603420972824,
             0.026638707146048546, -0.11189723014831543, -0.05527856573462486, 0.06916000694036484, 0.15311668813228607,
             0.058291394263505936, 0.0402587465941906, 0.0021729045547544956, 0.15846893191337585, 0.09890417754650116,
             -0.005400764290243387, 0.07505937665700912, -0.0839894711971283, -0.00036229839315637946, 0.01394029799848795,
             0.1044190526008606, -0.08917955309152603, -0.03601185232400894, -0.20460323989391327, 0.016246717423200607,
             -0.062035903334617615, -0.05667365714907646, -0.03599255532026291, -0.14755457639694214, -0.12382161617279053,
             0.10266990214586258, 0.12814970314502716, 0.02804051712155342, -0.10594826936721802, -0.05133979767560959,
             -0.06987598538398743, 0.07367149740457535, -0.05353302136063576, -0.058074820786714554, -0.09423889219760895,
             0.023743923753499985, -0.0011582287261262536, 0.20110568404197693, -0.10762393474578857, -0.02500303089618683,
             -0.02046511322259903, -0.17298772931098938, 0.010953104123473167, -0.10898572951555252, -0.021699463948607445,
             -0.061790622770786285, -0.02862698771059513, 0.020952550694346428, 0.08504325151443481, 0.05138469859957695,
             0.058499764651060104, 0.20120149850845337, -0.13180354237556458, -0.00010427933011669666, 0.07901207357645035,
             -0.028977714478969574, -0.07208176702260971, 0.1152845025062561, -0.17954254150390625, 0.0353381521999836,
             0.09222985804080963, 0.05652293562889099, -0.15525412559509277, -0.1463605761528015, 0.0045332713052630424,
             0.05012141913175583, -0.025123560801148415, -0.00891054980456829, -0.19589008390903473, -0.038104526698589325,
             0.09549462795257568, 0.07138647884130478, -0.11304236948490143]
        ]
        max_score = -1
        for tmp_feat in template_feat:
            tmp_socre = Counter.get_sim(self,person_feat, tmp_feat)
            max_score = max(max_score, tmp_socre)
        return max_score
